package com.up360.rapidcalc.aerolite.model
{
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.geom.Point;

    /**
     * @author Tunie
     * @date   May 2, 2013
     * 游戏元素
     */
    public class GameElement extends Sprite
    {
        protected var _ui:DisplayObject;
        
        public function GameElement()
        {
        }
        
        public function set ui(value:DisplayObject):void
        {
            checkUI();
            _ui = value;
            addChild(_ui);
        }
        
        /**
         *游戏元素的ui 
         */
        public function get ui():DisplayObject
        {
            return _ui;
        }

        public function clear():void
        {
            removeChild(_ui);
        }
        
        public function local():Point
        {
            return new Point(x,y);
        }
        
        protected function checkUI():void
        {
            if(_ui)
            {
               clear();
            }
        }
    }
}